<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="jt.classic.system.group.IGroup"%>
<%@ page import="jt.classic.system.user.IUser"%>
<%@ page import="org.limp.mine.Label"%>
<%@ page import="org.limp.mine.HTMLTool"%>
<%@ page import="org.limp.mine.Controller"%>
<%@ page import="org.limp.mine.DateTrimmer"%>
<%@ page import="jt.classic.system.wordbook.XWordbook"%>
<%
	String context = jt.classic.system.ISystem.getContextPath();
	Object[] result = (Object[]) request.getAttribute("result");
	Label label = (Label) result[1];
	Controller controller = (Controller) result[2];
	String pageNO = (String) result[3];
	List resultList = (List) result[0];

	Map query = (Map) request.getAttribute("query");

	List list = (List) request.getAttribute("list");

	/*列表类型*/
	String listtype = "directory";//(String)request.getAttribute("listtype");

	String qname = (String) query.get("qname");
	String qtype = (String) query.get("qtype");
	String qdirec = (String) query.get("qdirec");
	String qdirecid = (String) query.get("qdirecid");
	String qstatus = (String) query.get("qstatus");
	String qdate = (String) query.get("qdate");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>信息列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<jsp:include page="../head.jsp"></jsp:include>
<link rel="stylesheet" type="text/css" href="<%=context%>/app/info/css/directree.css" />
<script type="text/javascript" src="<%=context%>/app/info/js/lanmuselect.js"></script>
<script language="javascript">
  var chk = false;
  function checkall(thizz){
    var chks = document.getElementsByTagName("input");
    for(var i=0;i<chks.length;i++){
      if(chks[i].type == "checkbox"){
        chks[i].checked = !chk;
      }
    }
    
    chk = !chk;
  }
  
  function handleDeletes(){
    var rnt = false;
    var ids = "";
    var chks = document.getElementsByTagName("input");
    for(var i=0;i<chks.length;i++){
      if(chks[i].type == "checkbox" && chks[i].checked){
        rnt = true;
        ids += chks[i].value + ",";
      }
    }
    
    if(!rnt){
      alert("请选择要删除信息");
    }else if(confirm("确定删除")){
      createHidden("ids",ids.substring(0,ids.length - 1));
      document.form1.action = "<%=context%>/app/info.do?method=deleteinfo";
      document.form1.submit();
    }
  }
  
  function handleQuery(){
      document.form1.action = context + "/app/info.do?method=listinfo";
      document.form1.submit();
  }
  
  function handleView(id,tit){
      var url = context + "/app/info.do?method=viewinfo&id=" + id; 
      top.xwin(this,url,false,tit);
  }
  
  function handleInsert(){
      window.location.href =  context + "/app/info.do?method=neuinfo"; 
  }
  
  function handleEdit(id){
      window.location.href = context + "/app/info.do?method=editinfo&id=" + id + "&listtype=<%=listtype%>"; 
  }
  
  function handleDelete(id){
      if(confirm("确定删除")){
         window.location.href = context + "/app/info.do?method=deleteinfo&ids=" + id + "&ifdel=1&listtype=<%=listtype%>";
      }
  }
  
  function responseResult(ids, names){
      $('qdirecarea').innerHTML = "专题栏目 : " +  names;
      //handleQuery();
  }
</script>
<body>
<form name="form1" method="post" action="">
<input type="hidden"
	name="pageNO" value="<%=pageNO%>">
				<div align="left" style="margin-left:15px;margin-top:15px;">
				<span id="qdirecarea"><%if(!qdirec.equals("")){ %>所属栏目 : <%=qdirec%><%} %></span>&nbsp;
				<img src="<%=context %>/app/info/images/search.png" title="查询内容信息" style="cursor:hand;margin-bottom:-4px;" onclick="javascript:queryInfo();"/>查询
				<!--<img src="<%=context %>/app/info/images/addinfo.png" title="新建栏目信息" style="cursor:hand;margin-bottom:-4px;" onclick="javascript:handleInsert();"/>新建 -->
				<img src="<%=context %>/app/info/images/page_white_delete.png" title="删除内容信息" style="cursor:hand;margin-bottom:-4px;" onclick="javascript:handleDeletes();"/>删除
				<input type="hidden" id="qdirec" name="qdirec" value="<%=qdirec%>"/>
				<input type="hidden" id="qdirecid" name="qdirecid" value="<%=qdirecid%>"/>
				<input type="hidden" id="qname" name="qname" value="<%=qname%>"/>
				<input type="hidden" id="qstatus" name="qstatus" value="<%=qstatus%>"/>
				<input type="hidden" id="qdate" name="qdate" value="<%=qdate%>"/>
				</div>
				<table class="tbl" align="center" width="98%">
					<thead>
					<tr>
						<td title="全部选择/取消选择" onclick="javascript:checkall();" width="7%" align="center">全选</td>
						<td 
							width="33%" align="center">&nbsp;<font color="#4C4C4C"><b>标题</b></font></td>
						<%
						if (listtype.equals("type")) {
						%>
						<td 
							width="20%" align="center">&nbsp;<font color="#4C4C4C"><b>信息类别</b></font></td>
						<%
						}
						%>
						<td 
							width="20%" align="center">&nbsp;<font color="#4C4C4C"><b>所属栏目</b></font></td>
						<td 
							width="10%" align="center">&nbsp;<font color="#4C4C4C"><b>发布时间</b></font></td>
						<td
							width="10%" align="center">&nbsp;<font color="#4C4C4C"><b>发布人</b></font></td>
						<td 
							width="10%" align="center">&nbsp;<font color="#4C4C4C"><b>发布状态</b></font></td>	
						<td
							width="10%" align="center">&nbsp;</td>
					</tr>
					</thead>
					<tbody>
					<%
							if (resultList != null && !resultList.isEmpty()) {
							for (int i = 0; i < resultList.size(); i++) {
								Map info = (Map) resultList.get(i);
								String number = (String) info.get("PAGINATION_NUMBER");
								String title = HTMLTool.htmlEscape((String) info
								.get("IF_TITLE"));
								String itname = (String) info.get("IT_NAME");
								String idname = (String) info.get("ID_NAME");
								String date = (String) info.get("IF_DATE");
								String username = (String) info.get("IF_USERNAME");
								int status = Integer.parseInt((String)info.get("IF_STATUS"));
								String statusLabel = "";
								if(status == -1){
									statusLabel = "<font color=\"red\">未通过</font>";
								}else if(status == 0){
									statusLabel = "<font color=\"orange\">待审核</font>";
								}else if(status == 1){
									statusLabel = "<font color=\"green\">已发布</font>";
								}
								String id = (String) info.get("IF_ID");
					%>
					<tr onMouseOver="javascript:this.bgColor='#ffff99'"
						onmouseout=" javascript:this.bgColor='#ffffff'" bgColor="#ffffff">
						<td align="center"><input type="checkbox" name="chk" value="<%=id%>"><%=number%>
						</td>
						<td><div class="listtitle" style="width:300px;" title="<%=title%>"><a target="_blank" class="ititle"
							href="<%=context%>/app/info.do?method=viewinfo&id=<%=id%>"><%=title%></a></div></td>
						<%
						if (listtype.equals("type")) {
						%>
						<td align="left">&nbsp;<%=itname%></td>
						<%
						}
						%>
						<td align="center" title="<%=idname%>"><div class="listtitle" style="width:180px;"><%=idname%></div></td>
						<td align="center">&nbsp;<%=DateTrimmer.getYMD_LBL(date)%></td>
						<td align="center"><%=username%></td>
						<td align="center"><%=statusLabel%></td>
						<td align="center">&nbsp;<a
							href="javascript:void(0);" class="ititle" onclick="javascript:handleEdit('<%=id%>');">编辑</a> <a
							href="javascript:void(0);" class="ititle" onclick="javascript:handleDelete('<%=id%>');">删除</a>
						</td>
					</tr>
					<%
						}
						}
					%>
					</tbody>
				</table>
				<div id="pager"><div style="float:left;padding:5px;"><%=label.displayLabel()%>
					</div> <div style="float:right;padding:5px;"><%=label.startLabel()%> <%=label.previousLabel()%>
						<%=label.nextLabel()%> <%=label.endLabel()%> 
				<%=controller.getController().toString()%></div>
				</div>
				<%=controller.getControlScript(true)%>
</form>
</body>
</html>
